﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace CarRental.Control.User
{
    using Database;

    public partial class LoginForm : System.Web.UI.UserControl
    {
        protected void Page_Init(object sender, EventArgs e)
        {
            if (IsPostBack)
            {
                var userName = Request.Form["txtUserName"];
                var userPassword = Request.Form["txtUserPassword"];

                var user = Database.GetUserByUserName(userName);

                if (user != null && userPassword == user.Password)
                {
                    Session["user"] = user.Id;
                    Response.Redirect("/?ref=logok");
                }
            }
        }

        protected void Page_Load(object sender, EventArgs e)
        {

        }
    }
}